package com.zhaojonhy.zhaopangwb.utils;

import android.graphics.Bitmap;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.zhaojonhy.zhaopangwb.R;

public class ImageOptHelper {
	
	public static DisplayImageOptions getImgOptions() {
		DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
			.cacheOnDisc() //规定在disc中进行缓存
			.cacheInMemory() //在内存中进行缓存
			.bitmapConfig(Bitmap.Config.RGB_565)//图片的颜色类型
			.showStubImage(R.drawable.timeline_image_loading)//加载的时候图片
			.showImageForEmptyUri(R.drawable.timeline_image_loading)//图片Uri为空或是错误的时候显示的图片
			.showImageOnFail(R.drawable.timeline_image_failure)//失败的图片
			.build();
		return imgOptions;
	}
	
	
	public static DisplayImageOptions getAvatarOptions() {
		DisplayImageOptions	avatarOptions = new DisplayImageOptions.Builder()
			.cacheOnDisc()
			.cacheInMemory()
			.bitmapConfig(Bitmap.Config.RGB_565)
			.showStubImage(R.drawable.avatar_default)
			.showImageForEmptyUri(R.drawable.avatar_default)
			.showImageOnFail(R.drawable.avatar_default)
			.displayer(new RoundedBitmapDisplayer(999)) //图片圆角边
			.build();
		return avatarOptions;
	}
	
	
	public static DisplayImageOptions getCornerOptions(int cornerRadiusPixels) { //指定圆角半径
		DisplayImageOptions options = new DisplayImageOptions.Builder()
			.cacheOnDisc()
			.cacheInMemory()
			.bitmapConfig(Bitmap.Config.RGB_565)
			.showStubImage(R.drawable.timeline_image_loading)
			.showImageForEmptyUri(R.drawable.timeline_image_loading)
			.showImageOnFail(R.drawable.timeline_image_loading)
			.displayer(new RoundedBitmapDisplayer(cornerRadiusPixels)).build();
		return options;
	}
	
}
